package sz.szsmk.citizencard.ui.dzsmkavtivity;

import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.model.network.dzbean.res.MessageEvent;
import sz.szsmk.citizencard.model.network.dzbean.res.PreAuthResult;
import sz.szsmk.citizencard.util.Constant;
import sz.szsmk.citizencard.widget.GlobalVariables;


/**
 * Created by yangzhengwen on 2017/10/4.
 */

public class SafeSettingActivity extends AppBaseActivity {

    TextView tv_qr_click;
    boolean isFirst;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getComponent().inject(this);
        setContentView(R.layout.qr_activity_safe_setting);
          tv_qr_click = findViewById(R.id.tv_qr_click);
        tv_qr_click.setOnClickListener(this::onClickView);
        ImmersionBar.with(this)
                .fitsSystemWindows(true)
                .statusBarDarkFont(true, 0f)
                .statusBarColor(R.color.white).init();
    }

    public void onClickView(View v) {
        if (v.getId() == R.id.tv_qr_click) {
            Intent intent = new Intent(SafeSettingActivity.this, PayPwdSetActivity.class);
            intent.putExtra("type", isFirst);
            startActivity(intent);
        }
    }

    @Override
    protected CharSequence getTopTitle() {
        PreAuthResult preAuthResult = GlobalVariables.getInstance(this).getPreAuthResult();
        if (preAuthResult.getUserStatus().equals(Constant.QUERY_QR_RESULT_NO_PAY_PWD_SET)) {
            isFirst = true;
            tv_qr_click.setText("设置支付密码");
        } else {
            isFirst = false;
            tv_qr_click.setText("修改支付密码");
        }

        return "安全设置";
    }

    @Override
    public void onEvent(MessageEvent event) {
        if (MessageEvent.CODE_PASSWORD == event.getCode()) {
            finish();
        }
    }
}
